package com.im.gate.server;

import com.rou.im.framework.core.Dispatcher;
import com.rou.im.framework.core.Request;
import com.rou.im.framework.core.Response;

/**
 * <p>
 *     processor 就只是在执行目标方法的时候做的一些前置动作
 *
 *
 *
 *
 *
 *
 *     任务分发
 *     根据cmdid获取到具体的注册实例，然后去执行这个任务
 * </p>
 *
 * @author GaoShuangWen
 * @since 2020-04-24 16:17
 */
public class DispatcherImpl implements Dispatcher {
    @Override
    public Response dispatch(Request request) {
        return null;
    }

    /*private CmdRegistry registry ;

    public DispatcherImpl(CmdRegistry registry) {
        registry.register(new DefaultCmdInstance(1,new AuthMsgService()));
        this.registry = registry;
    }

    @Override
    public Response dispatch(Request request) {

        int cmdId = request.getRequestMsgHeaders().getCmdId();
        //获取具体的注册实例
        ServiceInstance serviceInstance = registry.get(cmdId);
        MsgService service = serviceInstance.getService();
        Object object = service.service(request);
        RequestContext context = RequestContextHolder.getContext();
        context.setResponse(() -> object);
        return context.getResponse();
    }*/
}
